/**
 * https://leetcode-cn.com/problems/group-anagrams/
 * @param {string[]} strs
 * @return {string[][]}
 */
 var groupAnagrams = function(strs) {
  const cache = new Map();
  for (let i = 0; i < strs.length; i++) {
      const bucket = new Array(26).fill(0);
      const word = strs[i];
      for (let j = 0; j < word.length; j++) {
          const charIndex = word.charCodeAt(j) - 97;
          // console.log(charIndex, word[j], bucket[charIndex]);
          bucket[charIndex] = bucket[charIndex] + 1;
      }
      const hash = bucket.join(',');
      // console.log(bucket);
      if (cache.has(hash)) {
          cache.get(hash).push(word);
      } else {
          cache.set(hash, [word]);
      }
  }
  console.log(cache);
  return [...cache.values()]
};